<load file="__PUBLIC__/header.html"/>
<ul class="top_title">
    <li>
        <p class="menu_title">管理员列表</p>
    </li>
    <li>|</li>
    <li>
        <a href="__CONTROL__/addUser" class="menu_title_a" >
            <i class="icon icon-plus-sign"></i>&nbsp;添加管理员
        </a>
    </li>
</ul>
<form action="__APP__/index/sort" method="post">
    <table class="table">
        <thead>
            <tr class="top_channel">
                <th align="center" width="60">ID</th>
                <th width='20'></th>
                <th align="center" width="26%">账号</th>
                <th align='center'>管理级别</th>

                <th align='center'>上次登录ip</th>
                <th align='center'>上次登录时间</th>

                <th align="center" width="100">状态</th>
                <th align="center">操作</th>
            </tr>
        </thead>
        <tbody>
      

        <foreach from="$list" value="$v">
            <tr class="top_channel">
           
                <td align="center">
                    <input type="text" disabled="disabled" value="{$v.id}"  class="input-medium"/>
                </td>
                <td width='20'></td>
                <td align="left" class="dis">
                    <a href="__CONTROL__/editUser?id={$v.id}">{$v.uname}</a>
                </td>
                <td align="center">
                  <if value="$v.class eq '1'">
                       <span style="color:#f60">超级管理员</span>
                    <else/>
                       普通管理员
                  </if>

                </td> 
                <td align='center'>
                 {$v.loginip}
                  
                </td>
                <td align='center'>{$v.logintime|date:"Y-m-d H:i:s",@@}</td>
                <td align="center">
                  <switch value="$v.status">
                    
                    <case value="1">
                      <span class="btn status" id='{$v.id}' style='color:#888'  status='{$v.status}' >正常</span>
                    </case>
                    <case value="2">
                      <!-- <span class="btn" style='color:#f60'>锁定</span> -->
                      <span class="btn status" id='{$v.id}' style='color:#f60'  status='{$v.status}' >锁定</span>
                    </case>
                  
                  </switch>
                   
                </td>
                <td align="center">
                    <if value="$_SESSION['ax_class'] eq '超级管理员'">
                        <a href="__CONTROL__/editProductList?id={$v.id}" class="isok btn edit">
                          <i class="icon icon-edit"></i>&nbsp;编辑
                      </a>
                      <a href="__CONTROL__/delUser?id={$v.id}" class="isok btn del">
                          <i class="icon icon-trash"></i>&nbsp;删除
                      </a>

                      <else/>
                      --
                    </if>
                     
                </td>
            </tr>
        </foreach>

            <tr class="top_channel">
                <td></td>
                <td align="center">
                    
                </td>
                <td colspan="5"> {$page}</td>
            </tr>
        </tbody>
    </table>
</form>
<script type='text/javascript'>
    $(function(){
        $('.del').click(function(){
            var cn = confirm('确定删除吗？');
            if(!cn){
                return false;
            }
        });
         //管理员状态ajax修改
          $('.status').live('click',function (){

            var zt = $(this).attr('status');
            var id = $(this).attr('id');
            ajaxChange(id,zt);
    
         });


   
    });

    function ajaxChange(id,status){
              status = status=='1'?'2':'1';
             $.post('__CONTROL__/'+'userListAjax',{'id':id,'status':status},function(data){
               if(data.id){//返回真，更新成功，修改前台css显示
               //  history.go(0);
              // alert(data.status);
                  // var status = data.status=='1'?'2':'1';
                  if(data.status == '1'){
                    $('#'+data.id).css('color','#888').attr('status',1).html('正常');
                  }else{
                    $('#'+data.id).css('color','#f60').attr('status',2).html('锁定');
                  }
                  
               
                   //  for(num in data.ids){
                   //     if(zt=='1'){
                   //          $('#'+data.ids[num]['id']).css('color','#f60').attr('zt','0').html('禁止');
                   //      }else{
                   //        //alert('222');
                   //         $('#'+data.ids[num]['id']).css('color','#888').attr('zt','1').html('使用');

                   //     }
                
                   // }
               // history.go(0);
                
               }else{
                  alert('出错了');
               }
            },"json");
        
    }
       // //修改使用状态
       //  function takeChange(data,zt){
       //   alert(data);
       //  }
</script>
</body>

</html>